[JAVA-SPRING;KOTLIN-SPRING] improvement: Allow autoXSpringPaginated for endpoints without sort - #24863
Conversation
Change autoXSpringPaginated from a boolean switch into a string-enum option
with three canonical values:
- none: disable auto-detection (default)
- page-size-sort: require page, size, and sort query parameters (identical
to the previous true behavior)
- page-size: require only page and size; sort may be absent (new)
The legacy true/false values are still accepted as deprecated aliases for
page-size-sort/none respectively. A deprecation warning is logged once via
the generator logger only when the option is explicitly set to true/false;
leaving the option unset keeps the silent none default with no warning.
- Add SpringPageableScanUtils.AutoPaginationMode enum and
resolveAutoPaginationMode() to centralize parsing/validation/deprecation
warnings shared by SpringCodegen and KotlinSpringServerCodegen.
- Update willBePageable, applyAutoXSpringPaginatedIfNeeded, and the
scanSortValidationEnums/scanPageableDefaults/scanPageableConstraints/
scanAll methods to take AutoPaginationMode instead of boolean.
- Replace the boolean CLI switch with a documented string-enum CLI option
in SpringCodegen and KotlinSpringServerCodegen (JavaCamelServerCodegen
inherits the behavior since it extends SpringCodegen).
- Update existing tests to use the new enum where internal signatures
changed; add new tests for page-size mode detection, deprecation
warnings (once when explicit, never when unset), and invalid values.
- Regenerate docs/generators/{spring,kotlin-spring,java-camel}.md.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
autoXSpringPaginated for endpoints without sort
…points-without-sort
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Preserve public string and deprecated boolean setter APIs for Spring and Kotlin Spring generators. Keep Kotlin autoXSpringPaginated absent from additionalProperties when it is unset, matching Spring behavior. Replace binding-dependent logback test capture with direct setter and option-state assertions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Share the immutable auto-pagination CLI enum map from SpringPageableScanUtils so Spring and Kotlin Spring generators cannot diverge. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
autoXSpringPaginated for endpoints without sortautoXSpringPaginated for endpoints without sort
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Re-trigger cubic
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit c6bcdb2.
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Requires human review: Auto-approval blocked by 2 unresolved issues from a previous review of this commit.
Re-trigger cubic
- Filter resolved parameters to in:query before checking required names in willBePageable(), so non-query parameters named 'page'/ 'size' no longer cause PAGE_SIZE auto-detection false positives. - Guard the legacy true/false deprecation warning in SpringCodegen/KotlinSpringServerCodegen's setAutoXSpringPaginated setters with a per-instance flag, so repeated setter/option- processing calls only log the warning once. - Add regression test for path/header parameters named page/size not triggering PAGE_SIZE auto-detection. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
- Restore logback ListAppender tests in SpringCodegenTest and
KotlinSpringServerCodegenTest asserting the legacy true/false
deprecation warning is logged exactly once when explicitly set and
not at all when unset, plus a new test proving the setter's
once-only guard suppresses a second warning when invoked twice with
the same legacy value.
- Add willBePageable_pageSizeSortMode_doesNotDetectPathParamNamedSort
to lock in the query-location filter for PAGE_SIZE_SORT (previously
only regression-tested for PAGE_SIZE).
- Add .in("query") to the page/size params in
applyAutoXSpringPaginatedIfNeeded_autoDisabled_doesNotSetExtension
and applyAutoXSpringPaginatedIfNeeded_explicitlyFalse_returnsFalseAndIsNotOverridden
so they exercise real auto-detection instead of passing trivially.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
All reported issues were addressed across 3 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Surefire runs test classes in parallel (parallel=classes, threadCountClasses=3), and SpringCodegen/KotlinSpringServerCodegen log through a shared per-class-name logback Logger inherited by all subclasses. A ListAppender attached to that logger during these tests could capture log events emitted by concurrently-running test classes on other threads, causing flaky/incorrect exactly-once and no-warning assertions. Filter captured events to the current test thread before asserting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…arning tests ListAppender.list is a plain ArrayList that concurrently-running test classes may still append to. Copy it while holding the appender monitor (the same lock AppenderBase.doAppend uses) before filtering by thread. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…points-without-sort
There was a problem hiding this comment.
All reported issues were addressed across 9 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…logic - Resolve and validate an explicitly supplied autoXSpringPaginated value in SpringCodegen and KotlinSpringServerCodegen regardless of library, so invalid values are no longer silently ignored for spring-http-interface / spring-declarative-http-interface. Write-back and usage remain gated by isPageableSupported(). - Move the once-only deprecation-warning guard into SpringPageableScanUtils.warnOnce(Consumer) shared by both generators. - Extract a countDeprecationWarnings(Runnable) helper in the Spring and Kotlin Spring codegen tests, and add regression tests for validation on unsupported libraries and for warnOnce. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
All reported issues were addressed across 6 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Move the ListAppender attach/detach, monitor-guarded snapshot and current-thread filtering duplicated in SpringCodegenTest and KotlinSpringServerCodegenTest into TestUtils.captureLogMessages, leaving a thin per-class countDeprecationWarnings wrapper. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The setter is only called once per generation (from processOpts), so the warn-once machinery guarded a case that never occurs in practice. - Make SpringPageableScanUtils.resolveAutoPaginationMode(String) pure. - Add package-private warnIfDeprecatedAutoPaginationValue, called once from processOpts in SpringCodegen and KotlinSpringServerCodegen; it shares value normalization with resolve. - Remove warnOnce and the per-generator guard fields. - Adapt tests and drop the ones made redundant by the processOpts-logs-exactly-once tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…SpringPaginated-for-endpoints-without-sort
…tionValue instance method LOGGER in SpringPageableScanUtils is intentionally a non-static instance field (enforced by ArchUnitRulesTest to limit memory use across generator instances), so it cannot be referenced from a static method. Change warnIfDeprecatedAutoPaginationValue from static to instance scope and call it via the existing pageableUtils instance in SpringCodegen and KotlinSpringServerCodegen. Update the corresponding unit tests to invoke it on a SpringPageableScanUtils instance. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
autoXSpringPaginatedpreviously only auto-detected Pageable operations that had all three ofpage,size, andsortquery parameters. Many real-world paginated endpoints intentionally omitsort(fixed ordering, or sorting handled elsewhere), so those operations were silently skipped by auto-detection and users had to fall back to manually annotating every such operation withx-spring-paginated: true. A plain boolean also couldn't express "detect with just page/size" without breaking the existing all-three-params behavior for consumers relying on it, so the option is widened to a string enum with an explicitpage-sizemode, whiletrue/falseare kept working (with a deprecation warning) so existing specs and configs don't break.Change autoXSpringPaginated from a boolean switch into a string-enum option with three canonical values:
none: disable auto-detection (default)page-size-sort: requirepage,size, andsortquery parameters (identical to the previoustruebehavior)page-size: require onlypageandsize;sortmay be absent (new)The legacy
true/falsevalues are still accepted as deprecated aliases forpage-size-sort/nonerespectively. A deprecation warning is logged once via the generator logger only when the option is explicitly set totrue/false; leaving the option unset keeps the silentnonedefault with no warning.SpringPageableScanUtils.AutoPaginationModeenum andresolveAutoPaginationMode()to centralize parsing/validation/deprecation warnings shared bySpringCodegenandKotlinSpringServerCodegen.willBePageable,applyAutoXSpringPaginatedIfNeeded, and thescanSortValidationEnums/scanPageableDefaults/scanPageableConstraints/scanAllmethods to takeAutoPaginationModeinstead ofboolean.SpringCodegenandKotlinSpringServerCodegen(JavaCamelServerCodegeninherits the behavior since it extendsSpringCodegen).page-sizemode detection, deprecation warnings (once when explicit, never when unset), and invalid values.docs/generators/{spring,kotlin-spring,java-camel}.md.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
Summary by cubic
Converts
autoXSpringPaginatedfrom a boolean switch into a string-enum option so Spring generators can auto-detect Pageable endpoints that have onlypageandsize(nosort). Previously auto-detection required all three parameters; now apage-sizemode is available, and the defaultnonedisables auto-detection.none,page-size-sort, andpage-size;page-size-sortmatches the oldtruebehavior.true/falsevalues still work but log a deprecation warning once when explicitly set; the unset default stays silent.page,size, orsortno longer triggers auto-detection.isPageableSupported().additionalProperties. The deprecation warning is an instance method onSpringPageableScanUtilsso it honors the ArchUnit rule limiting logger use across generator instances.SpringPageableScanUtilsand shared bySpringCodegen,KotlinSpringServerCodegen, andJavaCamelServerCodegen.page-sizedetection, query-parameter filtering, deprecation warnings, invalid values, and setter behavior; deprecation-warning tests filter log events by thread and snapshot them under the appender lock to stay stable under parallel runs.Written for commit 8aa3102. Summary will update on new commits.